<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>

<%
	String path= request.getContextPath();
	System.out.print(path);
	String basePath = request.getScheme() + "://"    + request.getServerName() + ":" + request.getServerPort()    + path + "/";
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>上报</title>
<link rel="stylesheet" type="text/css" href="<%=path %>/pages/admin/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="<%=path %>/pages/admin/easyui/themes/icon.css">
<script type="text/javascript" src="<%=path %>/pages/admin/easyui/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="<%=path %>/pages/admin/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.3"></script>
<style type="text/css">
textarea{font-size:12px;}
.clearfix{clear:both;}
#left{height:100%;float:left;}
#map{height:100%;width:65%;float:left;border-left:2px solid #bcbcbc;}
</style>
<script>
$(function(){
			$('#test').datagrid({
				title:'',
				iconCls:'',
				width:750,
				height:450,
				nowrap: true,
				autoRowHeight: false,
				striped: true,
				collapsible:true,
				sortName: 'code',
				sortOrder: 'desc',
				remoteSort: false,
				pagination:true,
				onClickRow:function(rowIndex, rowData){
					//alert(rowData.name);
					$("#t #the_value").html(rowData.value);
					var datas = decodeURI("name="+rowData.name);
					$.ajax({
						type:"POST",
						url:'<%=path%>/pages/admin/Company!getComjson.do',
						data:datas,
						success:function(data){
							//alert(data.name)
							$("#t").window('open');
							$("#t #name").val(data.name);
							$("#t #address").val(data.address);
							$("#t #law_person").val(data.law_person);
							$("#t #fund").val(data.registered_fund+"万元");
							$("#t #company_type").val(data.company_type);
							$("#t #business_type").val(data.business_type);
							$("#t #location").val(data.post_long +","+ data.post_lat);
							$("#t #certificate").html(data.certificate);
							init();
						}
					});
				}
			});
			var p = $('#test').datagrid('getPager');
			
			$(p).pagination({
				onBeforeRefresh:function(){
					alert('before refresh');
				},
				total:'<s:property value="page.totalNum" />' 				
			});
			$("#btn").click(function(){
				$("#e #name").attr("readonly",false);
				$("#e #address").attr("readonly",false);
				$("#e #law_person").attr("readonly",false);
				$("#e #fund").attr("readonly",false);
				$("#e #company_type").attr("readonly",false);
				$("#e #business_type").attr("readonly",false);
			});
			$("#btns").click(function(){
				document.saveForm.submit();
				$('#test').datagrid('reload');
				alert("保存成功");
			});
		});
</script>
</head>
<body>
<div style="font-size:12px;margin:10px 0;"><strong>您的位置：上报管理</strong></div>
<table class="easyui-datagrid" id="test"> 
	<thead>  
	     <tr> 
	        <th data-options="field:'ck'"></th> 
	        <th data-options="field:'code'">Code</th>  
	        <th data-options="field:'name'" width="200px">公司名称</th>  
	        <th data-options="field:'value'" width="343px">上报内容</th> 
	        <th data-options="field:'date'" >上报时间</th> 
	        <th data-options="field:'status'">状态</th>  
	      </tr>  
	</thead>
	<tbody>
		<s:iterator value="page.list" status="rowstatus">
			<tr>
				<td><s:checkbox name="ck"></s:checkbox></td>
				<td><s:property
						value="#rowstatus.index+1+page.pageNum*page.pageSize" /></td>
				<td><s:property value="name" /></td>
				<td ><s:property value="value" /></td>
				<td></td>
				<td><s:set name="status" value="status" />
				<s:if test="#status==false">上报未处理</s:if>
				<s:else>
				上报已处理	
				</s:else>
				</td>				
			</tr>
		</s:iterator>
	</tbody>
</table>
<div style="font-size:11px;margin:10px 0;color:red;">*点击行进行上报处理</div>
<div id="t" class="easyui-window" title="企业详情"   
        style="width:900px;height:450px;padding:10px;background:#fafafa;"  
        data-options="iconCls:'icon-save',closed:true,
                collapsible:true">
       <div class="easyui-layout" data-options="fit:true">
			<div data-options="region:'center',border:false" style="padding:10px;background:#fff;border:1px solid #ccc;">
				<div id="left">       	
			               <s:form id="saveForm" name="saveForm" action="Company!updateDes" namespace="/pages/admin">     	
        						<p> 公司名称 ：<input id="name" name="name" type="text" size=25 readonly="readonly" /></p>        
						        <p>	法人代表  ：<input id="law_person" name="law_person" type="text" size=25 readonly="readonly"/></p>
						        <p>	注册资金  ：<input id="fund" type="text" name="registered_fund" size=25 readonly="readonly"/></p>
						    	<p>	公司类型  ：<input id="company_type" type="text" name="company_type" size=25 readonly="readonly"/></p>
						    	<p>	住所  ：&nbsp;&nbsp;&nbsp;&nbsp;<input id="address" type="text" name="address" size=25 readonly="readonly"/></p>
						    	<div><div style="float:left;">行业类型  ：</div><div style="float:left;"><textarea id="business_type" name="business_type" readonly="readonly"></textarea></div><div class="clearfix"></div></div>
						    	<p> 法人代码  ：<span id="certificate"></span></p>
						    	<p>坐标：<input id="location" name="location" type="text" size=20 readonly="readonly"/></p>
						    	</s:form>
			    	<div><a id="btn" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'">编辑</a>  
			    		 <a id="btns" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save'">保存</a>   
			    		 <a id="btnqs" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save'">重新定位</a>  
    		 </div>
    	</div>
    	<div id="map" ></div>
			</div>
			<div data-options="region:'south',border:false" style="padding:5px 0;">
				<div><strong>上报内容</strong>：<span id="the_value"></span></div>
				<a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onclick="javascript:alert('ok')">上报处理</a>
			</div>
		</div>
</div>
</body>
</html>
<script type="text/javascript">
//初始化地图定义
function init(){
var map = new BMap.Map("map");
var point = new BMap.Point(121.559243,29.825056);
map.centerAndZoom(point,12);
map.addControl(new BMap.NavigationControl()); //添加默认缩放平移控件
map.enableScrollWheelZoom();    //启用滚轮放大缩小，默认禁用
//alert($("#e #location").val());

var lo = new Array();
lo = $("#t #location").val().split(",");
//alert(lo[0]);
//alert(lo[1]);
var marker = new BMap.Marker(new BMap.Point(lo[0],lo[1]));
map.addOverlay(marker);
var infoWindow = new BMap.InfoWindow('<strong>'+$("#t #name").val()+'</strong>');
marker.openInfoWindow(infoWindow);
function showInfo(e){
		alert(e.point.lng + ", " + e.point.lat);
		$("#t #location").val(e.point.lng + ", " + e.point.lat);
		var marker = new BMap.Marker(new BMap.Point(e.point.lng,e.point.lat));
		map.addOverlay(marker);
}
$("#btnqs").click(function(){
	map.clearOverlays();
	map.addEventListener("click", showInfo);
	
	});
}
</script>